
//移入移出
require(["../../static/conf/config.js"], function () {
    require(["jquery"], function ($) {
        let $city = $(".current-city")
        let $cityList = $(".current-city-list")
        let $message = $(".header-message")
        let $messageList = $(".message-list-header")
        let $applist = $("#app-list")
        let $APP = $("#APP")
        let $weixin = $(".footer-weixin")
        let $weixinErweima = $(".footer-weixin-erweima")
        let $footApp = $(".footer-app")
        let $appErweima = $(".footer-app-erweima")
        let $headerUser = $(".header-user")
        let $HeaderUser = $("#header-user")
        $headerUser.mouseenter(function() {
            $HeaderUser.show("slow");
        })
        $HeaderUser.mouseleave(function(){
            $HeaderUser.hide();
        })
        $weixin.mouseenter(function() {
            $weixinErweima.show("slow");
        })
        $weixin.mouseleave(function(){
            $weixinErweima.hide();
        })
        $footApp.mouseenter(function() {
            $appErweima.show("slow");
        })
        $footApp.mouseleave(function(){
            $appErweima.hide();
        })
        $APP.mouseenter(function() {
            $applist.show("slow");
        })
        $applist.mouseleave(function(){
            $applist.hide();
        })
        $city.mouseenter(function() {
            $cityList.show("slow");
        })
        $cityList.mouseleave(function(){
            $cityList.hide();
        })
        $message.mouseenter(function() {
            $messageList.show("slow");
        })
        $messageList.mouseleave(function(){
            $messageList.hide();
        })
    })
})

//登录状态的检测和退出登录
require(["../../static/conf/config.js"], function () {
    require(["jquery"], function ($) {
        $(document).ready(function () {

            let obj = localStorage.getItem('logined');
            if (obj !== null) {
                $(".logined").show()
                $(".not-login").hide()
            }
            if (obj == null) {
                $(".logined").hide()
                $(".not-login").show()
            }

            $(".quit").click(function () {
                localStorage.removeItem("logined")
                $(".logined").hide()
                $(".not-login").show()
            })

        })

    })
})

require(["../../static/conf/config.js"], function () {
    require(["jquery"], function ($) {
        $("#bannerImgList").children("li").mouseenter(function () {
            $(this).addClass("active").siblings().removeClass("active");
            $(".left-img-box img:eq("+$(this).index()+")").show().siblings().hide();
        })

        $(".details-Specifications-size dd ul li").click(function () {
            $(".details-Specifications-size dd ul li").children("a").removeClass()
            $(this).children("a").addClass("active")
            $(".details-img-box").removeClass("active");
            $(".details-img-box:eq("+$(this).index()+")").addClass("active");
            // $(".details-Specifications-size").show();
        })
        
        $(".recommend-list").children("li").mouseenter(function(){
            $(".recommend-cart:eq("+$(this).index()+")").css({
                opacity : "1"
            })
        })
        $(".recommend-list").children("li").mouseleave(function(){
            $(".recommend-cart:eq("+$(this).index()+")").css({
                opacity : "0"
            })
        })
        let t = $(".details-Specifications-size dd ul li").siblings()
        console.log(t)

    })
})

//购物车:将购买数据存储到本地
let g =[];
    require(["../../static/conf/config.js"], function () {
            require(["jquery"], function ($) {
                $(".details-but-cart").click(function(){
                    let img = $(".left-img-box img:first-child").attr("src")
                    console.log(img)
                    let name = $(".pro-details-title").text()
                    console.log(name)
                    let size = $(".details-Specifications-size dd li a.active").text()
                    console.log(size)
                    let tableware = $(".details-img-box.active .details-options-laid").text()
                    console.log(tableware)
                    let price = $(".details-img-box.active .details-price span").text()
                    console.log(price)
                    let link = "http://localhost:9999/pages/detail/detail.html"
                    console.log(link)
                   
                    g.push({
                        img:img,
                        name:name,
                        size:size,
                        tableware:tableware,
                        price:price,
                        link:link
                    })
                    console.log(g)
                    localStorage.setItem("cart",JSON.stringify(g));
                    let cart = JSON.parse(localStorage.getItem("cart"))
                    console.log(cart)
                    
                })
                
            })
        })